<template>
  <div>

    <Head/>
    <left/>

    <div style="position: absolute;top: 60px;left: 200px">
      <h1>申请进来了</h1>
      <div v-for="i in params['params']" :key="i.name">
        <p v-if="i.type=='select'">{{ i.name }}
          <select name="" id="" v-model="form[i.name]">
            <option :value="j.type" v-for="j in i['value']" :key="j.id">{{ j.name }}</option>
          </select>
        </p>
        <p v-else-if="i.type=='text'">
          {{ i.name }}<input type="text" v-model="form[i.name]">
        </p>
        <p v-else-if="i.type=='date'">{{ i.name }}<input type="datetime-local" v-model="form[i.name]"></p>
        <p v-else-if="i.type=='radio'">{{ i.name }}<input type="radio" v-model="form[i.name]"></p>
        <p v-else-if="i.type=='checkbox'">{{ i.name }}<input type="checkbox" v-model="form[i.name]"></p>
      </div>
      <div>
        <p v-for="i in bume" :key="i.id">{{i.name}}<input type="checkbox" :value="i.level" v-model="approver"></p>
      </div>
      <van-button @click="subimt">提交</van-button>
      <ul>
        <li v-for="(i,j) in jialist['params']" :key="i.id">{{j}}::::{{i}}</li>
      </ul>
      <ul>
        <li v-if="jialist.status==0">状态：未通过</li>
        <li v-else>状态：通过</li>
      </ul>
    </div>
  </div>

</template>

<script>
import head from "@/components/head";
import left from "@/components/left";
import maxios from "@/http/axios";

export default {
  components: {
    "Head": head,
    "left": left
  },
  name: "show_shenq",
  data() {
    return {
      id: this.$route.query.id,
      holiday: {},
      params: [],
      form: {},
      approver:[],
      bume : [],
      jialist:[],
      userid:localStorage.getItem('userid')

    }
  },
  methods: {
    getholiday() {
      maxios('/work/holiday?id=' + this.id, 'get').then(res => {
        // this.holiday = res.list
        this.params = res.list
        console.log(this.holiday)
      })
    },
    //获取部门
    get_bumenlist(){
      maxios('/compan/zhiwu','get').then(res=>{
        this.bume = res.list
      })
    },
    subimt(){
      let title = this.params['name']
      let approver = JSON.stringify(this.approver)
      let foom = JSON.stringify(this.form)
      let formdata = new FormData()
      formdata.append('title',title)
      formdata.append('approver',approver)
      formdata.append('foom',foom)
      maxios('/users/add_qingjia','post',formdata).then(res=>{
        if(res.code==200){
          alert('ok')
        }
      })
    },
    get_jia(){
      maxios('/users/add_qingjia?userid='+this.userid,'get').then(res=>{
        this.jialist = res.list
      })
    }
  },
  mounted() {
    this.getholiday()
    this.get_bumenlist()
    this.get_jia()
  }
}
</script>

<style scoped>

</style>